package com.lyncs.ods.modules.goods.service.impl;

import com.lyncs.ods.constant.LyncsOdsConstant;
import com.lyncs.ods.modules.goods.model.SkuDetail;
import com.lyncs.ods.modules.goods.mapper.SkuDetailMapper;
import com.lyncs.ods.modules.goods.service.SkuDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * sku详细信息表 服务实现类
 * </p>
 *
 * @author alex
 * @since 2022-02-15
 */
@Service
public class SkuDetailServiceImpl extends ServiceImpl<SkuDetailMapper, SkuDetail> implements SkuDetailService {

    @Override
    public List<Long> getSkuIdListByAttrs(@NotNull Long spuId, @NotNull Map<Long, String> attrs, Integer offset, Integer pageSize) {
        Set<Long> attrIds = attrs.keySet();
        String attrValues = attrs.values().stream().collect(Collectors.joining(LyncsOdsConstant.Common.COMMA));
        return this.baseMapper.getSkuIdListByAttrs(spuId, attrIds, attrValues, offset, pageSize);
    }
}
